// 评论集合

// 引入mongoose
const mongoose = require('mongoose');

// 创建评论Schema
const commentSchema = new mongoose.Schema({
    content: {
        type: String,
        maxlength: 200,
    },
    author: {
        type: mongoose.Schema.Types.ObjectId,
        ref: 'User',
        required: true,
    },
    article: {
        type: mongoose.Schema.Types.ObjectId,
        ref: 'Article',
        required: true,
    },
    commentDate: {
        type: Date,
        default: Date.now,
    }
})


// 注册评论schema
const Comment = mongoose.model('Comment', commentSchema);

// 导出
module.exports = {
    Comment
}